package com.alex.algorithm.easy;

public class ValidPalindrome {

    public static void main(String[] args) {
        System.out.println(isPalindrome("abba"));
        System.out.println(isPalindrome("dabbbd"));
        System.out.println(isPalindrome("dbCCbd"));
    }

    private static boolean isPalindrome(String str) {
        int left = 0;
        int right = str.length() - 1;
        while(left < right) {
            if (str.charAt(left) == str.charAt(right)) {
                left++;
                right--;
            }else {
                break;
            }
        }
        return right <= left;
    }
}
